/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package job.manager.client.mb;

import java.util.ArrayList;
import java.util.Collection;
import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.faces.model.SelectItem;
import job.manager.db.ec.UserGroupsEB;
import job.manager.db.sb.UserRemote;

/**
 *
 * @author Administrator
 */
public class UserGroupsMB {

    @EJB
    private UserRemote userBean;
    private Collection<UserGroupsEB> userGroups;

    /** Creates a new instance of UserGroups */
    public UserGroupsMB() {
    }

    @PostConstruct
    public void onInit() {
        this.userGroups = userBean.getUserGroups();
    }

    public ArrayList<SelectItem> getUserGroups() {
        ArrayList<SelectItem> itemList = new ArrayList<SelectItem>();

        ArrayList<UserGroupsEB> ugs = new ArrayList(userGroups);

        for (UserGroupsEB ug : ugs) {
            SelectItem a = new SelectItem();
            a.setLabel(ug.getGroupName());
            a.setValue(ug.getId().toString());
            itemList.add(a);
        }
        return itemList;
    }
}
